package com.yanqu.road.server.cmd.peakstronghold;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.PeakStrongholdWarProto;
import com.yanqu.road.pb.player.PlayerProto;
import com.yanqu.road.pb.union.UnionActivityGroupProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.peakstronghold.CrossPeakStrongholdMgr;
import com.yanqu.road.server.manager.user.CrossUserMgr;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_PEAK_STRONGHOLD_UPDATE_USER_BASE_INFO, desc = "更新玩家基础数据")
public class CrossPeakStrongholdUpdateUserBaseCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        UnionActivityGroupProto.BaseUnionActivityGroupMsg syncMsg = UnionActivityGroupProto.BaseUnionActivityGroupMsg.parseFrom(packet.getBytes());
        PeakStrongholdWarProto.CrossPeakHoldUpdateUserBaseMsg req = PeakStrongholdWarProto.CrossPeakHoldUpdateUserBaseMsg.parseFrom(syncMsg.getMsg());
        for (PeakStrongholdWarProto.UserBaseMsg userBaseMsg : req.getUserBaseMsgListList()) {
            UserBaseInfo userBaseInfo = PlayerBasePb.parseToUserBaseInfo(userBaseMsg.getUserBaseMsg());
            CrossUserMgr.updateUserBaseInfoChange(userBaseMsg.getUserId(), userBaseInfo);
        }

    }

    @Override
    public void sendData() {

    }
}
